<!--
 * @description  :运输首页的快递list
 * @descriptionDetail:运输首页的快递list
 * @copyright    : 浙江烟草
 * @author       : dw
 * @create       : 2022-10-09 22:21:21
-->
<template>
  <view class="lt-root" @tap="itemClick">
    <view class="lt-row It-title-state">
      <view class="It-title-sty">
        <view class="lt-left-label">
          快递公司：
        </view>
        <view class="lt-right-value">
          {{ itemInfo.expressCompanyName }}
        </view>
      </view>
      <view>
        <u-tag
          style="flex-shrink: 0; margin-right: 20rpx" :spStyle="getSpStyle(itemInfo)" mode="dark"
          shape="circle" :text="isActiveName"
        ></u-tag>
      </view>
    </view>
    <view class="lt-row">
      <text class="lt-left-label">
        登记单位：
      </text>
      <text class="lt-right-value">
        {{ itemInfo.orgName }}
      </text>
    </view>
    <view class="lt-row">
      <text class="lt-left-label">
        所在城市：
      </text>
      <text class="lt-right-value">
        {{ $store.state.areaObj[itemInfo.countyCode] || $store.state.areaObj[itemInfo.cityCode] || $store.state.areaObj[itemInfo.provCode] || '' }}
      </text>
    </view>
    <view class="lt-row">
      <text class="lt-left-label">
        网点：
      </text>
      <text class="lt-right-value">
        {{ itemInfo.point }}
      </text>
    </view>
  </view>
</template>

<script>
const sysCodeColors = {
  1: {
    color: '#0079F2',
    borderColor: '#0079F2',
    backgroundColor: '#E0ECFF',
  },
  0: {
    color: '#AC0000',
    borderColor: '#AC0000',
    backgroundColor: '#F2CCCC',
  },
};
export default {
  name: 'ListItemExpress',
  props: {
    itemInfo: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      isActive: this.itemInfo.isActive ? '1' : '0',
      isActiveName: this.itemInfo.isActive ? '启用' : '停用',
    };
  },
  // watch: {
  //   'itemInfo.isActive'(newValue, oldValue) {
  //     this.isActive = newValue ? '1' : '0';
  //     this.isActiveName = newValue ? '启用' : '停用';
  //   },
  //   'itemInfo': {
  //     // 监听的对象
  //     deep: true, // 深度监听设置为 true
  //     handler: function (newV, oldV) {
  //       // if (this.$u.test.isEmpty(newV.cityCode) && this.$u.test.isEmpty(newV.countyCode)) {
  //       //   this.local = newV.provCodeName;
  //       // } else if (this.$u.test.isEmpty(newV.countyCode)) {
  //       //   this.local = newV.provCodeName + "/" + newV.cityCodeName;
  //       // } else if (!this.$u.test.isEmpty(newV.countyCode)){
  //       //   this.local = newV.provCodeName + "/" + newV.cityCodeName + "/" + newV.countyCodeName;
  //       // } else if (!this.$u.test.isEmpty(newV.provCode)){
  //       //   this.local = "";
  //       // }
  //       this.local = this.$store.state.areaObj[newV.countyCode] || this.$store.state.areaObj[newV.cityCode] || this.$store.state.areaObj[newV.provCode] || '';
  //     },
  //   },
  // },
  created() {
    // this.init();
  },
  methods: {
    init() {
      // if (this.$u.test.isEmpty(this.itemInfo.cityCode) && this.$u.test.isEmpty(this.itemInfo.countyCode)) {
      //   this.local = this.itemInfo.provCodeName;
      // } else if (this.$u.test.isEmpty(this.itemInfo.countyCode)) {
      //   this.local = this.itemInfo.provCodeName + '/' + this.itemInfo.cityCodeName;
      // } else if (!this.$u.test.isEmpty(this.itemInfo.countyCode)) {
      //   this.local = this.itemInfo.provCodeName + '/' + this.itemInfo.cityCodeName + '/' + this.itemInfo.countyCodeName;
      // } else if (!this.$u.test.isEmpty(this.itemInfo.provCode)) {
      //   this.local = '';
      // }
      this.local =
					this.$store.state.areaObj[this.itemInfo.countyCode] ||
					this.$store.state.areaObj[this.itemInfo.cityCode] ||
					this.$store.state.areaObj[this.itemInfo.provCode] ||
					'';
    },
    itemClick() {
      this.setRouteParam(this.itemInfo);
      // 跳转到 窝点的详情页面
      this.$u.route('pages/intelligence/intelligenceFilesInfo/expressArchive');
    },
    getSpStyle(it) {
      if (it.isActive == this.isActive) {
        return sysCodeColors[this.isActive] || {};
      } else if (it.isActive == this.isActive) {
        return sysCodeColors[this.isActive] || {};
      }
    },
  },
};
</script>

<style scoped lang="scss">
	@import '../list_item.scss';
</style>
